package com.jz.community.moduleshopping.confirmOrder.task;

import android.app.Activity;

import com.jz.community.basecomm.bean.BaseResponseInfo;
import com.jz.community.basecomm.constant.Constant;
import com.jz.community.basecomm.net.OkHttpUtil;
import com.jz.community.basecomm.task.ITaskCallbackListener;
import com.jz.community.basecomm.task.RxTask;
import com.jz.community.basecomm.utils.JsonUtils;
import com.jz.community.basecomm.utils.Preconditions;

import cn.shequren.communityPeople.pay.bean.CardInfo;

/**
 * Created by Tony.Fan on 2018/6/27 10:47
 */
public class GetCardBalanceTask extends RxTask<String, Integer, CardInfo> {

    private Activity activity;
    private ITaskCallbackListener taskListener;

    public GetCardBalanceTask(Activity activity,
                              ITaskCallbackListener taskListener) {
        super(activity);
        this.activity = activity;
        this.taskListener = taskListener;
    }

    @Override
    protected CardInfo doInBackground(String... params) {
        // 执行请求
        String result = OkHttpUtil.get(Constant.MONEY_INFO);
        CardInfo info = null;
        if (!Preconditions.isNullOrEmpty(result)) {
            info = JsonUtils.parseObject(result, CardInfo.class);
        }
        return info;
    }

    @Override
    protected void onPostExecute(CardInfo result) {
        // 执行结果回调函数
        taskListener.doTaskComplete(result);
        super.onPostExecute(result);
    }

    @Override
    protected void onPreExecute() {
        super.onPreExecute();
    }

    @Override
    protected void onCancelled() {
        super.onCancelled();
    }


}